package com.jsoft.manager;

import com.jsoft.model.MenuGroupDao;
import com.jsoft.model.core.ManagerImpl;

import java.util.List;

/**
 * Date: 28.09.13
 * Time: 10:03
 */

public class MenuGroupManagerImpl extends ManagerImpl<MenuGroupDao> implements MenuGroupManager {
    protected MenuGroupManagerImpl() {
        super(MenuGroupDao.class);
    }

    @Override
    public MenuGroupDao getByMenuIdAndMenuGroupId(Integer menuId, Integer menuGroupId) {
        List<MenuGroupDao> list = getEntityManager().createQuery("select m from MenuGroupDao m" +
                " where m.menu.id = " + menuId +
                " and m.id = " + menuGroupId, MenuGroupDao.class).getResultList();
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }
}
